com.willowtreeapps.android.shared
Class OAKImageLoader

java.lang.Object
  extended by com.github.droidfu.imageloader.ImageLoader
      extended by com.willowtreeapps.android.shared.OAKImageLoader
All Implemented Interfaces:
Runnable

public class OAKImageLoader
extends ImageLoader
implements Runnable


Field Summary
static int INTERNAL_CACHING
           
static int NO_DISK_CACHING
           
static int PREFER_INTERNAL
           
static int PREFER_SD
           
static int SD_CACHING
           
static boolean spinLoading
           
 
Fields inherited from class com.github.droidfu.imageloader.ImageLoader
BITMAP_EXTRA, DEFAULT_POOL_SIZE, DEFAULT_RETRY_HANDLER_SLEEP_TIME, executor, expirationInMinutes, HANDLER_MESSAGE_ID, IMAGE_URL_EXTRA, numRetries
 
Method Summary
static void clearCache()
           
protected  android.graphics.Bitmap downloadImage(boolean toDiskOnly)
           
static android.graphics.drawable.Drawable getDefaultError()
           
static android.graphics.drawable.Drawable getDefaultLoading()
           
static OAKImageCache getImageCache()
           
static String getPrintedUrl(String originalUrl, ImageTransformation... transformations)
           
static void initialize(android.content.Context context, int cacheType)
          This method must be called before any other method is invoked on this class.
static boolean isSafeMode()
           
 void notifyImageLoaded(String url, android.graphics.Bitmap bitmap)
           
static void preCache(String[] urls, ImageTransformation... transformations)
          Downloads images in urls array and applies transformations to each.
protected  byte[] retrieveImageData()
          Uses a BufferedHttpEntity to write to a byte array, to ensure that the complete data is loaded.
 void run()
          The job method run on a worker thread.
static void setDefaultError(android.graphics.drawable.Drawable defaultError)
          Sets the default error drawable- to use when there was an error in loading the image.
static void setDefaultLoading(android.graphics.drawable.Drawable defaultLoading)
          Sets the default "dummy" drawable- to use while loading.
static void setLoading(android.widget.ImageView v, android.graphics.drawable.Drawable loading)
          Sets an image in the loading state.
static void setSafeMode(boolean safeMode, int bytesPerPixel)
          If Safe Mode is enabled, checks are performed to ensure that a bitmap will fit in available memory before it is inflated.
static void setSpinning(android.view.View v)
          Gets a "spinning" animation to use with a loading dialog.
static void start(String imageUrl, android.widget.ImageView imageView)
           
static void start(String imageUrl, android.widget.ImageView imageView, android.graphics.drawable.Drawable dummyDrawable, android.graphics.drawable.Drawable errorDrawable)
           
static void start(String imageUrl, android.widget.ImageView imageView, android.graphics.drawable.Drawable dummyDrawable, android.graphics.drawable.Drawable errorDrawable, ImageTransformation... transformations)
           
static void start(String imageUrl, android.widget.ImageView imageView, ImageTransformation... transformations)
           
protected static void start(String imageUrl, android.widget.ImageView imageView, OAKImageLoaderHandler handler, android.graphics.drawable.Drawable dummyDrawable, android.graphics.drawable.Drawable errorDrawable, ImageTransformation... transformations)
           
static void start(String imageUrl, OAKImageLoaderHandler handler)
           
static void start(String imageUrl, OAKImageLoaderHandler handler, android.graphics.drawable.Drawable dummyDrawable, android.graphics.drawable.Drawable errorDrawable)
           
static void start(String imageUrl, OAKImageLoaderHandler handler, android.graphics.drawable.Drawable dummyDrawable, android.graphics.drawable.Drawable errorDrawable, ImageTransformation... transformations)
           
static void start(String imageUrl, OAKImageLoaderHandler handler, ImageTransformation... transformations)
           
 
Methods inherited from class com.github.droidfu.imageloader.ImageLoader
downloadImage, initialize, initialize, setMaxDownloadAttempts, setThreadPoolSize, start, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_DISK_CACHING

public static final int NO_DISK_CACHING
See Also:
Constant Field Values

INTERNAL_CACHING

public static final int INTERNAL_CACHING
See Also:
Constant Field Values

SD_CACHING

public static final int SD_CACHING
See Also:
Constant Field Values

PREFER_INTERNAL

public static final int PREFER_INTERNAL
See Also:
Constant Field Values

PREFER_SD

public static final int PREFER_SD
See Also:
Constant Field Values

spinLoading

public static boolean spinLoading
Method Detail

initialize

public static void initialize(android.content.Context context,
                              int cacheType)
This method must be called before any other method is invoked on this class.

Parameters:
context - the current context
cacheType - What kind of disk caching, if any, should be used.
NO_DISK_CACHING: Use memory only.
INTERNAL_CACHING: Use device's internal memory.
SD_CACHING: Attempt to use an SD card for caching but use only memory if one isn't present.
PREFER_INTERNAL: Try to use internal memory, then fall back on SD, then fall back on memory only.
PREFER_SD: Try to use SD, then fall back on internal, then fall back on memory only.

getImageCache

public static OAKImageCache getImageCache()

start

public static void start(String imageUrl,
                         OAKImageLoaderHandler handler)

start

public static void start(String imageUrl,
                         OAKImageLoaderHandler handler,
                         ImageTransformation... transformations)

start

public static void start(String imageUrl,
                         android.widget.ImageView imageView,
                         android.graphics.drawable.Drawable dummyDrawable,
                         android.graphics.drawable.Drawable errorDrawable)

start

public static void start(String imageUrl,
                         android.widget.ImageView imageView,
                         android.graphics.drawable.Drawable dummyDrawable,
                         android.graphics.drawable.Drawable errorDrawable,
                         ImageTransformation... transformations)

start

public static void start(String imageUrl,
                         android.widget.ImageView imageView)

start

public static void start(String imageUrl,
                         android.widget.ImageView imageView,
                         ImageTransformation... transformations)

start

public static void start(String imageUrl,
                         OAKImageLoaderHandler handler,
                         android.graphics.drawable.Drawable dummyDrawable,
                         android.graphics.drawable.Drawable errorDrawable,
                         ImageTransformation... transformations)

start

public static void start(String imageUrl,
                         OAKImageLoaderHandler handler,
                         android.graphics.drawable.Drawable dummyDrawable,
                         android.graphics.drawable.Drawable errorDrawable)

start

protected static void start(String imageUrl,
                            android.widget.ImageView imageView,
                            OAKImageLoaderHandler handler,
                            android.graphics.drawable.Drawable dummyDrawable,
                            android.graphics.drawable.Drawable errorDrawable,
                            ImageTransformation... transformations)

getPrintedUrl

public static String getPrintedUrl(String originalUrl,
                                   ImageTransformation... transformations)

preCache

public static void preCache(String[] urls,
                            ImageTransformation... transformations)
Downloads images in urls array and applies transformations to each. Transformed images are then written to disk cache for fast retrieval later with ImageLoader.start().

Parameters:
urls -
transformations -

run

public void run()
Description copied from class: ImageLoader
The job method run on a worker thread. It will first query the image cache, and on a miss, download the image from the Web.

Specified by:
run in interface Runnable
Overrides:
run in class ImageLoader

notifyImageLoaded

public void notifyImageLoaded(String url,
                              android.graphics.Bitmap bitmap)
Overrides:
notifyImageLoaded in class ImageLoader

downloadImage

protected android.graphics.Bitmap downloadImage(boolean toDiskOnly)
Parameters:
toDiskOnly -
Returns:
the generated bitmap if toDiskOnly == true, otherwise null

retrieveImageData

protected byte[] retrieveImageData()
                            throws IOException
Uses a BufferedHttpEntity to write to a byte array, to ensure that the complete data is loaded. New version 8/11/11 by cceckman to try to fix 2.3 issues.

Overrides:
retrieveImageData in class ImageLoader
Throws:
IOException

clearCache

public static void clearCache()

getDefaultLoading

public static android.graphics.drawable.Drawable getDefaultLoading()

setDefaultLoading

public static void setDefaultLoading(android.graphics.drawable.Drawable defaultLoading)
Sets the default "dummy" drawable- to use while loading.

Parameters:
defaultLoading -

getDefaultError

public static android.graphics.drawable.Drawable getDefaultError()

setDefaultError

public static void setDefaultError(android.graphics.drawable.Drawable defaultError)
Sets the default error drawable- to use when there was an error in loading the image.

Parameters:
defaultError - the Drawable of the default error image.

setSpinning

public static void setSpinning(android.view.View v)
Gets a "spinning" animation to use with a loading dialog. Rotates at 1HZ and does not stop.


setLoading

public static void setLoading(android.widget.ImageView v,
                              android.graphics.drawable.Drawable loading)
Sets an image in the loading state.

Parameters:
v -
loading -

isSafeMode

public static boolean isSafeMode()

setSafeMode

public static void setSafeMode(boolean safeMode,
                               int bytesPerPixel)
If Safe Mode is enabled, checks are performed to ensure that a bitmap will fit in available memory before it is inflated. This applies to any Bitmaps generated by OAKImageLoader, including those used internally for applying transformations.

Parameters:
safeMode -
bytesPerPixel -


Copyright © 2011. All Rights Reserved.